export const swings1 = world.querySelectorAll('#秋千-1');
export const swings2 = world.querySelectorAll('#秋千-1-1');

swings1.forEach((swing) => {
    const Quat = swing.meshOrientation;
    const Pos = swing.position;
    swing.animate(
        [
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1),
                position: swing.position,
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(45) * 5, Math.sin(45) * 5)
                ),
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(45) * 5, Math.sin(45) * 5)
                ),
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1),
                position: swing.position,
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    -Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(-45) * 5, Math.sin(-45) * 5)
                ),
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    -Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(-45) * 5, Math.sin(-45) * 5)
                ),
            },
        ],
        {
            iterations: Infinity,
            direction: GameAnimationDirection.WRAP,
            duration: 16 * 5,
        }
    );
});

swings2.forEach((swing) => {
    const Quat = swing.meshOrientation;
    const Pos = swing.position;
    swing.animate(
        [
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1),
                position: swing.position,
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    -Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(-45) * 5, Math.sin(-45) * 5)
                ),
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    -Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(-45) * 5, Math.sin(-45) * 5)
                ),
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1),
                position: swing.position,
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(45) * 5, Math.sin(45) * 5)
                ),
            },
            {
                meshOrientation: new GameQuaternion(0, 0, 0, 1).rotateZ(
                    Math.PI / 4
                ),
                position: Pos.add(
                    new GameVector3(0, Math.cos(45) * 5, Math.sin(45) * 5)
                ),
            },
        ],
        {
            iterations: Infinity,
            direction: GameAnimationDirection.WRAP,
            duration: 16 * 5,
        }
    );
});
